﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace AmazonBookLinker
{
  internal class BookHelper
  {
    internal static IEnumerable<string> GetMacroNames()
    {
      Type self = typeof(Book);
      FieldInfo[] fields = self.GetFields( BindingFlags.Public | BindingFlags.Instance );

      foreach ( var field in fields )
        if ( Attribute.IsDefined( field, typeof(TemplateMacrosAttribute) ) )
        {
          var attribute = (TemplateMacrosAttribute)Attribute.GetCustomAttribute( field, typeof(TemplateMacrosAttribute) );
          yield return attribute.TemplateName;
        }
    }
  }
}